﻿/*
 * @Author: Song Xinxin
 * @Date: 2022-10-28 15:14:53
 * @LastEditors: Song Xinxin
 * @LastEditTime: 2022-11-08 11:39:44
 * @FilePath: \WYW_0419_Oasis\JavaScripts\UI\UIStart.ts
 * @Description: 
 * 
 * Copyright (c) 2022 by error: git config user.name && git config user.email & please set dead value or install git, All Rights Reserved. 
 */
import { ModuleManager, UI } from "odin";
import { ModuleC_Game } from "../Modules/Game/Module_Game";
import { ModuleC_Sound } from "../Modules/Sound/Module_Sound";
import { UIDeath } from "./UIDeath";
import { UIGame } from "./UIGame";
import { UI_StartUI } from "./UITemplate";

export class UIStart extends UI_StartUI
{

	Player:GamePlay.Player;
	
	protected async onShow():Promise<void>
	{
		ModuleManager.instance.getModule(ModuleC_Sound).playStartBGM();

		this.Player = await GamePlay.asyncGetCurrentPlayer();
		//点击开始游戏前角色不能移动
		this.Player.character.canMove = false;
		ModuleManager.instance.getModule(ModuleC_Game).PlayerReady();
		this.button_start.onClicked().add(()=>
		{
			ModuleManager.instance.getModule(ModuleC_Sound).ButtonSound();
			//点击开始游戏后切换UI，角色可以移动
			UI.instance.hidePanel(UIStart);
			UI.instance.hidePanel(UIDeath);
			UI.instance.showPanel(UIGame);
			this.Player.character.canMove = true;
			ModuleManager.instance.getModule(ModuleC_Game).startTime();
		});	
		
	}
}
